home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / MacSense / 1995 / MacSense 05⁄95 ƒ / MacSense May 1995 / MacSense May 1995.rsrc / TEXT_135.txt < prev    next >
Encoding:
Text File  |  1995-04-30  |  5.9 KB  |  69 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.    This month MacSense debuts our new Getting Started column with Part 1 of an 
  24.    introduction to AppleScripting. Parts 2 and 3 will follow in subsequent issues.
  25.  
  26. Relax.  Don‚Äôt be scared.  AppleScript is part of the Macintosh System Software, and that means it‚Äôs as easy as pie.  I‚Äôll let you in on a little secret:  AppleScript is the most incredible computer technology of the ‚Äô90‚Äôs.  In this month‚Äôs Getting Started column, you‚Äôre going to learn how to get started with AppleScript, and you‚Äôre gonna love  it!
  27.  
  28. But, you ask, isn‚Äôt AppleScript a (gasp!) programming language ?  How could Apple expect me to know how to program?  How could it possibly be worth all that trouble?  Read on, and everything will become very clear to you.
  29.  
  30. Let‚Äôs begin by learning the concepts. The purpose of AppleScripting is to automate repetitive tasks.  In some ways, this makes it similar to ‚ÄúQuicKeys‚Äù and other macro programs. The System 7.5 Finder can be "scripted" to do virtually anything that you can do with your mouse.  Many applications, including WordPerfect 3.1, Microsoft Word 6, Microsoft Excel 5, FileMaker Pro, and QuarkXPress are fully scriptable. Many of the things these programs do can be activated with AppleScripts (which you can write)‚Äîtasks such as opening, searching and formatting documents, copying, moving or backing up files, and exchanging data between programs.
  31.  
  32. This can be a giant time saver. AppleScripts work by sending ‚ÄúEvents,‚Äù or messages, to the programs you wish to automate.  It doesn‚Äôt use any ‚Äúhacks‚Äù to perform its work, but instead sends commands to your applications which make them do the work for you.  This means that you can write small computer programs which will automatically make your Macintosh applications do whatever you want, automatically.  If you have repetitive tasks that you find yourself performing often, this can be a great time-saver.
  33.  
  34. Once you get started with AppleScript, you‚Äôll be amazed at how handy (and magical!) it is to quickly whip up tiny Mac programs that can speed your work up.  Here are some quick examples:
  35.  
  36.         To make your monitor display 8-bit color (256 colors):
  37.                      Set Monitor Depth 8
  38.     
  39.         To make your monitor display 4-bit color (16 colors):
  40.                      Set Monitor Depth 4
  41.  
  42.         To change your Mac‚Äôs speaker‚Äôs volume to 3:
  43.                      Set Volume 3
  44.  
  45. Simple scripts like this can be part of larger scripts, or simple, ‚Äústand-alone‚Äù Macintosh applications.  It‚Äôs also easy to make a script support drag-n-drop, so that you can drop files and folders on your script and have the script do something to the file, such as back it up.
  46.  
  47. This month‚Äôs MacSense package includes a number of AppleScripts for you to use, including the Monitor Depth and Volume scripts shown above.  If you find some that you really like, you can add them to your Apple Menu Items folder for quick access.  Every online service has an AppleScript Forum, where you can find more scripts which you can use.  
  48.  
  49. System 7.5 comes with AppleScript and a new version of the Finder which is scriptable.  Purchasing the System 7.5 upgrade is probably the best way to get started with AppleScript, but it‚Äôs not the only way.  PlainTalk, which comes with AV Macs, includes AppleScript, and there are several other ways to get it, such as purchasing Apple‚Äôs AppleScript Scripter Kit or various other Apple products.  AppleScript is also included with Derrick Schneider‚Äôs book, ‚ÄúThe Tao of AppleScript‚Äù.  To use an AppleScript, you only need to have System 7 or later and the AppleScript extension installed in your Extensions Folder.  To edit scripts, you need an Apple application called ‚ÄúScript Editor,‚Äù which comes with System 7.5 and the other AppleScript kits.  Of course, you‚Äôll also need the Application which the script is designed to automate.
  50.  
  51. AppleScript lets you look at and use a program‚Äôs data, too.  You could use it to open every text file on your hard disk, look for a particular word in each file, and copy the paragraph containing that word and the name of the document it came from into a new file.  
  52.  
  53. You can write scripts to backup your data, or perform some time-consuming task very quickly.  You can also make two or three applications work together through AppleScript.  For instance, FileMaker and Quark XPress are both scriptable.  Many people keep information in databases which they need to print out with desktop publishing software.  Catalogs and telephone books, for instance, can only be produced by combining a database program with a desktop publishing program.
  54.  
  55. Let‚Äôs say you worked for a mail-order company, and you keep information about every single product you sell in a database‚Äîthe part number, a description, perhaps a picture, and the price.  This information is updated constantly, as different vendors offer new products and different prices.  Every two weeks, this product information needs to be copied into a catalog which you create with Quark XPress. 
  56.  
  57. For years, a job like this was pure grunt work; you‚Äôd have to copy and paste items from FileMaker into Quark one at a time, hundreds of times. With AppleScript, you now don‚Äôt have to!  Instead, you can just create an AppleScript which automatically copies information about each product out of the database and pastes it into a Quark XPress document. When the script is finished running, you'll be ready to add graphics and pizzaz, instead of wasting your time copying and pasting. 
  58.  
  59. Hopefully, this will give you some idea of both the power and ease of AppleScript.  Try ‚Äúplaying‚Äù with the AppleScripts included with this month‚Äôs issue.  Next month, we‚Äôll go under the hood, and look at the source code behind those scripts.  This will let you customize the scripts so that you can put AppleScript to work.
  60.  
  61.  
  62.  
  63.  
  64.  
  65. Marshall Goldberg is a Forum Consultant for the Macintosh Multimedia Forum on America Online. He welcomes feedback at AFCMARS@aol.com. 
  66.  
  67.  
  68.  
  69.